<!--
 * @Author: your name
 * @Date: 2022-01-12 14:16:45
 * @LastEditTime: 2022-01-12 14:45:12
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \0112\浮动.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>浮动</title>
    <style>
        /* 布局居中：1.设置宽度2.左右外边距为auto */
        .box{
            width: 1200px;
            height: 600px;
            background: whitesmoke;
            margin: 0 auto 0 auto;
        }
        .box div{
            width: 200px;
            height: 200px;
        }
        /* 块级元素占一整行，无论宽高多少 */
        /* 浮动：float: left;float: right;
            1.浮动可以让元素脱离原本的文档流 
            2.不占空间
            3.浮动在最上面
            */
        .left{
            background: yellow;
            float: left;
        }
        .right{
            background: violet;
            float: right;
        }
        .box .box3{
            width: 300px;
            height: 300px;
            background: rgb(84, 190, 240);
        }
        .blue{
            background: blue;
        }
        .new_box{
            width: 1200px;
            background: rgb(241, 29, 29);
            margin: 0 auto 0 auto;
        }
        .new_box div{
            width: 200px;
            height: 200px;
        }
        .normal{
            width: 300px;
            height: 300px;
            background: violet;
            clear: both;/*清除浮动影响*/
        }
        ul{
            background: turquoise;
            width: 1200px;
            margin: 0 auto;
        }
        ul li{
            width: 200px;
            height: 200px;
            float: left;
            /* background: palevioletred; */
        }
        /* .clearfix:before{
            content: "123";
        } */
        .clearfix:after{
            content: "";
            display: block;
            clear: both;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="left"></div>
        <div class="right"></div>
        <div class="box3"></div>
    </div>
    <div class="box">
        <div class="right"></div>
        <div class="blue"></div>
    </div>
    <div class="box">
        <div class="blue"></div>
        <div class="right"></div>
    </div>
    <div class="new_box">
        <div class="left"></div>
        <div class="right"></div>
    </div>
    <div class="normal"></div>
    <ul class="clearfix">
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>
</body>
</html>
